/*
 * CustomerOption.java
 *
 * Created on 18 March 2009, 13:48
 */

package uk.co.exahertz.friendlysociety.gui;
import java.awt.Toolkit;
import uk.co.exahertz.friendlysociety.core.*;
import javax.swing.ButtonGroup;

/**
 *
 * @author  rjf4
 */
public class CustomerOption extends javax.swing.JFrame {
     private Core core;
     private Customer customer;

    /** Creates new form CustomerOption */
    public CustomerOption(final Core core, final Customer customer) {
        if(core == null) throw new IllegalArgumentException("The core " +
                "instance must not be null.");
        if(customer == null) throw new IllegalArgumentException("The " +
                "customer instance must not be null.");
       
        this.core = core;
        this.customer = customer;
        setIconImage(Toolkit.getDefaultToolkit().getImage(
        CustomerOption.class.getResource("images/friendlyicon.jpg")));
        initComponents();
        jRadioButton6.setSelected(true);
        setResizable(false);    //disables maximize button
        
        ButtonGroup group = new ButtonGroup();
        group.add(jRadioButton1);
        group.add(jRadioButton2);
        group.add(jRadioButton3);
        group.add(jRadioButton4);
        group.add(jRadioButton5);
        group.add(jRadioButton6);
        
        setTitle("Customer Options for " + customer.getForenames() + " " +
                customer.getSurname());
        core.addForm(this);
    }
    
    @Override
    public void dispose() {
        core.removeForm(this);
        super.dispose();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jRadioButton6 = new javax.swing.JRadioButton();
        jButtonOK = new javax.swing.JButton();
        jRadioButton1 = new javax.swing.JRadioButton();
        jRadioButton3 = new javax.swing.JRadioButton();
        jRadioButton4 = new javax.swing.JRadioButton();
        jRadioButton2 = new javax.swing.JRadioButton();
        jSeparator1 = new javax.swing.JSeparator();
        jRadioButton5 = new javax.swing.JRadioButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("uk/co/exahertz/friendlysociety/gui/Bundle"); // NOI18N
        setTitle(bundle.getString("CustomerOption.title")); // NOI18N

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));

        jLabel1.setText(bundle.getString("CustomerOption.jLabel1.text")); // NOI18N

        jRadioButton6.setBackground(new java.awt.Color(255, 255, 255));
        jRadioButton6.setText(bundle.getString("CustomerOption.jRadioButton6.text")); // NOI18N

        jButtonOK.setBackground(new java.awt.Color(255, 255, 255));
        jButtonOK.setText(bundle.getString("CustomerOption.jButtonOK.text")); // NOI18N
        jButtonOK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonOKActionPerformed(evt);
            }
        });

        jRadioButton1.setBackground(new java.awt.Color(255, 255, 255));
        jRadioButton1.setText(bundle.getString("CustomerOption.jRadioButton1.text")); // NOI18N

        jRadioButton3.setBackground(new java.awt.Color(255, 255, 255));
        jRadioButton3.setText(bundle.getString("CustomerOption.jRadioButton3.text")); // NOI18N

        jRadioButton4.setBackground(new java.awt.Color(255, 255, 255));
        jRadioButton4.setText(bundle.getString("CustomerOption.jRadioButton4.text")); // NOI18N

        jRadioButton2.setBackground(new java.awt.Color(255, 255, 255));
        jRadioButton2.setText(bundle.getString("CustomerOption.jRadioButton2.text")); // NOI18N

        jRadioButton5.setBackground(new java.awt.Color(255, 255, 255));
        jRadioButton5.setText(bundle.getString("CustomerOption.jRadioButton5.text")); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 312, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(52, Short.MAX_VALUE))
            .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 406, Short.MAX_VALUE)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jRadioButton5)
                    .addComponent(jRadioButton6)
                    .addComponent(jRadioButton4)
                    .addComponent(jRadioButton1)
                    .addComponent(jRadioButton3)
                    .addComponent(jRadioButton2))
                .addGap(198, 198, 198))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(305, Short.MAX_VALUE)
                .addComponent(jButtonOK, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(48, 48, 48))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jRadioButton1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jRadioButton2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jRadioButton3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jRadioButton4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jRadioButton5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jRadioButton6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButtonOK)
                .addContainerGap(15, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 374, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        setBounds(460, 350, 382, 258);
    }// </editor-fold>//GEN-END:initComponents

private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOKActionPerformed
    if(jRadioButton6.isSelected()){
        dispose();
    }
    else if(jRadioButton1.isSelected()) {
        CustomerDetails customerDetails = new CustomerDetails(core, customer);
        customerDetails.setVisible(true);
        dispose();
            }
    else if(jRadioButton4.isSelected()) {
        SetupMortgage mortgage = new SetupMortgage(core, customer);
        mortgage.setVisible(true);
        dispose();
            }
    else if(jRadioButton3.isSelected()) {
        MortgageDetails md = new MortgageDetails(core, customer);
        md.setVisible(true);
        dispose();
            }
    else if(jRadioButton5.isSelected()) {
        AddEmployment ae = new AddEmployment(core, customer);
        ae.setVisible(true);
        dispose();
            }
   
         
    
}//GEN-LAST:event_jButtonOKActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonOK;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JRadioButton jRadioButton1;
    private javax.swing.JRadioButton jRadioButton2;
    private javax.swing.JRadioButton jRadioButton3;
    private javax.swing.JRadioButton jRadioButton4;
    private javax.swing.JRadioButton jRadioButton5;
    private javax.swing.JRadioButton jRadioButton6;
    private javax.swing.JSeparator jSeparator1;
    // End of variables declaration//GEN-END:variables

}
